
CXXFLAGS=-I$(INCLUDE_PATH) -L$(LIB_PATH) 
LDLIBS=-pthread

PROJECT_DIR=../../ec2

all:main main2 main3 main4_rpc_server main4_rpc_client main4_rpc_server2 main4_rpc_client2 main4_rpc_test_server main4_rpc_test_client main5_progress

DEBUGFLAG=-DDEBUG_INFO_HUB_IMPL
MAIN_SRC=main.cpp ./infoHub.cpp ./infoHub_impl.cpp ${PROJECT_DIR}/public/_public.cpp ${PROJECT_DIR}/public/utility.cc
MAIN_HEAD=infoHub_impl.h ${PROJECT_DIR}/public/_public.h ${PROJECT_DIR}/public/utility.h

main:${MAIN_SRC} ${MAIN_HEAD}
	g++ ${DEBUGFLAG} -g -o main ${MAIN_SRC} $(CXXFLAGS) $(LDLIBS)

MAIN2_SRC=main2.cpp ./infoHub.cpp ./infoHub_impl.cpp ${PROJECT_DIR}/public/_public.cpp ${PROJECT_DIR}/public/utility.cc
MAIN2_HEAD=infoHub.h infoHub_impl.h ${PROJECT_DIR}/public/_public.h ${PROJECT_DIR}/public/utility.h

main2:${MAIN2_SRC} ${MAIN2_HEAD}
	g++ -g -o main2 ${MAIN2_SRC} $(CXXFLAGS) $(LDLIBS)

MAIN3_SRC=main3.cpp ./infoHub.cpp ./infoHub_impl.cpp ${PROJECT_DIR}/public/_public.cpp ${PROJECT_DIR}/public/utility.cc
MAIN3_HEAD=infoHub.h infoHub_impl.h rateStatistic.h rateStatisticTable.h ${PROJECT_DIR}/public/_public.h ${PROJECT_DIR}/public/utility.h

main3:${MAIN3_SRC} ${MAIN3_HEAD}
	g++ -g -o main3 ${MAIN3_SRC} $(CXXFLAGS) $(LDLIBS)


#------- infohub rpc test -----------

MAIN4_RPC_INCLUDE=-I/usr/local/include/
MAIN4_RPC_LIB_DIR=-L/usr/local/lib/
MAIN4_RPC_LIB=-lrpc

# main4 infohub rpc test 1

MAIN4_RPC_CLIENT_SRC=main4_rpc_client.cpp ./infoHub.cpp ./infoHub_impl.cpp ${PROJECT_DIR}/public/_public.cpp ${PROJECT_DIR}/public/utility.cc
MAIN4_RPC_CLIENT_HEAD=infoHubRpcClient.h infoHub.h infoHub_impl.h rateStatistic.h rateStatisticTable.h ${PROJECT_DIR}/public/_public.h ${PROJECT_DIR}/public/utility.h

main4_rpc_client:${MAIN4_RPC_CLIENT_SRC} ${MAIN4_RPC_CLIENT_HEAD}
	g++ -g -o main4_rpc_client ${MAIN4_RPC_CLIENT_SRC} $(CXXFLAGS) $(LDLIBS) ${MAIN4_RPC_INCLUDE} ${MAIN4_RPC_LIB_DIR} ${MAIN4_RPC_LIB}

MAIN4_RPC_SERVER_SRC=main4_rpc_server.cpp ./infoHub.cpp ./infoHub_impl.cpp ${PROJECT_DIR}/public/_public.cpp ${PROJECT_DIR}/public/utility.cc
MAIN4_RPC_SERVER_HEAD=infoHubRpcServer.h infoHub.h infoHub_impl.h rateStatistic.h rateStatisticTable.h ${PROJECT_DIR}/public/_public.h ${PROJECT_DIR}/public/utility.h

main4_rpc_server:${MAIN4_RPC_SERVER_SRC} ${MAIN4_RPC_SERVER_HEAD}
	g++ -g -o main4_rpc_server ${MAIN4_RPC_SERVER_SRC} $(CXXFLAGS) $(LDLIBS) ${MAIN4_RPC_INCLUDE} ${MAIN4_RPC_LIB_DIR} ${MAIN4_RPC_LIB}

# main4 infohub rpc test 2

MAIN4_RPC_CLIENT2_SRC=main4_rpc_client2.cpp ./infoHub.cpp ./infoHub_impl.cpp ${PROJECT_DIR}/public/_public.cpp ${PROJECT_DIR}/public/utility.cc
MAIN4_RPC_CLIENT2_HEAD=infoHubRpcClient.h infoHub.h infoHub_impl.h rateStatistic.h rateStatisticTable.h ${PROJECT_DIR}/public/_public.h ${PROJECT_DIR}/public/utility.h

main4_rpc_client2:${MAIN4_RPC_CLIENT2_SRC} ${MAIN4_RPC_CLIENT2_HEAD}
	g++ -g -o main4_rpc_client2 ${MAIN4_RPC_CLIENT2_SRC} $(CXXFLAGS) $(LDLIBS) ${MAIN4_RPC_INCLUDE} ${MAIN4_RPC_LIB_DIR} ${MAIN4_RPC_LIB}

MAIN4_RPC_SERVER2_SRC=main4_rpc_server2.cpp ./infoHub.cpp ./infoHub_impl.cpp ${PROJECT_DIR}/public/_public.cpp ${PROJECT_DIR}/public/utility.cc
MAIN4_RPC_SERVER2_HEAD=infoHubRpcServer.h infoHub.h infoHub_impl.h rateStatistic.h rateStatisticTable.h ${PROJECT_DIR}/public/_public.h ${PROJECT_DIR}/public/utility.h

main4_rpc_server2:${MAIN4_RPC_SERVER2_SRC} ${MAIN4_RPC_SERVER2_HEAD}
	g++ -g -o main4_rpc_server2 ${MAIN4_RPC_SERVER2_SRC} $(CXXFLAGS) $(LDLIBS) ${MAIN4_RPC_INCLUDE} ${MAIN4_RPC_LIB_DIR} ${MAIN4_RPC_LIB}

# main4 rpc test 

MAIN4_RPC_TEST_SERVER_SRC=main4_rpc_test_server.cpp 
MAIN4_RPC_TEST_SERVER_HEAD=
main4_rpc_test_server:${MAIN4_RPC_TEST_SERVER_SRC} ${MAIN4_RPC_TEST_SERVER_HEAD}
	g++ -g -o main4_rpc_test_server ${MAIN4_RPC_TEST_SERVER_SRC} $(CXXFLAGS) $(LDLIBS) ${MAIN4_RPC_INCLUDE} ${MAIN4_RPC_LIB_DIR} ${MAIN4_RPC_LIB}

MAIN4_RPC_TEST_CLIENT_SRC=main4_rpc_test_client.cpp 
MAIN4_RPC_TEST_CLIENT_HEAD=
main4_rpc_test_client:${MAIN4_RPC_TEST_CLIENT_SRC} ${MAIN4_RPC_TEST_CLIENT_HEAD}
	g++ -g -o main4_rpc_test_client ${MAIN4_RPC_TEST_CLIENT_SRC} $(CXXFLAGS) $(LDLIBS) ${MAIN4_RPC_INCLUDE} ${MAIN4_RPC_LIB_DIR} ${MAIN4_RPC_LIB}

MAIN5_PROGRESS_SRC=main5_progress.cpp ./infoHub.cpp ./infoHub_impl.cpp
MAIN5_PROGRESS_HEAD=./infoHub.h ./infoHub_impl.h
main5_progress:${MAIN5_PROGRESS_SRC} ${MAIN5_PROGRESS_HEAD}
	g++ -g -o main5_progress ${MAIN5_PROGRESS_SRC} $(CXXFLAGS) $(LDLIBS) 

clean:
	rm -rf main main2 main3 main4_rpc_client main4_rpc_server main4_rpc_test_server main4_rpc_test_client main4_rpc_server2 main4_rpc_client2 main5_progress
